package com.erpx.api.goods;

import com.erpx.api.WdtClient;
import com.erpx.api.param.PlatformGoodsSpecCreateParam;
import com.erpx.utils.JsonUtils;
import com.erpx.api.CommonConstants;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PlatformGoodsCreateService {
    public static void goodsApiSpecPush() throws Exception {
        WdtClient client = new WdtClient(CommonConstants.sid, CommonConstants.appkey, CommonConstants.appSecret, CommonConstants.baseUrl);

        Map<String, String> params = new HashMap<String, String>();
        PlatformGoodsSpecCreateParam specCreateParam = new PlatformGoodsSpecCreateParam();
        specCreateParam.setShopId("7");
        specCreateParam.setPlatformId("127");
        List<PlatformGoodsSpecCreateParam.PlatformGoodsSpecItemParam> specItemList = new ArrayList<>();
        PlatformGoodsSpecCreateParam.PlatformGoodsSpecItemParam specItemParam =
            new PlatformGoodsSpecCreateParam.PlatformGoodsSpecItemParam();
        specItemParam.setSpecId("S20240805002");
        specItemParam.setGoodsId("S20240805001");
        specItemParam.setGoodsNo("自研商品20240805001");
        specItemParam.setGoodsName("自研商品名称1");
        specItemParam.setSpecNo("自研规格20240805001");
        specItemParam.setPrice("1000000000000000000000000000000000000000000");
        specItemParam.setStatus("1");
        specItemList.add(specItemParam);
        specCreateParam.setGoodsList(specItemList);
        params.put("api_goods_info", JsonUtils.serialize(specCreateParam));
        try {
            String response = client.execute("api_goodsspec_push.php", params);
            System.out.println(response);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
